package ch.usi.inf.pf2;

import java.io.IOException;

import junit.framework.TestCase;


/**
 * @author Ebrisa Savina Mastrodicasa
 */

public class TestReadSpreadSheetFile extends TestCase 
{
	
	/**
	 * Check that cutLineOnComma() method cuts correctly 
	 * a line containing a comma.
	 */
	public void testCutLineOnComma()
	{
		String line = "\"Hello world\",\" this is me.\",";
		String[] s = ReadSpreadSheetFile.cutLineOnComma(line);
		assertEquals(2, s.length);
		assertEquals("Hello world", s[0]);
		assertEquals(" this is me.", s[1]);
	}
	
	
	/**
	 * Check that tryToOpenFile() method return false if the given
	 * file doesn't exist. Otherwise (if we try to pass as parameter
	 * testRead.CVS that is located in the folder bin/..) true.
	 * @throws IOException 
	 */
	public void testTryToOpenFile() throws IOException
	{
		ReadSpreadSheetFile rssf = new ReadSpreadSheetFile("foobar");
		assertEquals(false, rssf.tryToOpenFile());
	}
}
